package com.sk.myview;

import com.sk.water.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class MultiChoiceExpandAdapter extends BaseExpandableListAdapter {
	private String[] groupName;
	private String[] groupDescribe;
	private String[][] childName;
	private Context context;
	private String resultString;
	private CheckBox checkBox;

	public MultiChoiceExpandAdapter(Context context) {
		this.context = context;
	}

	public void setGroupName(String[] groupName) {
		this.groupName = groupName;
	}

	public void setGroupDescribe(String[] groupDescribe) {
		this.groupDescribe = groupDescribe;
	}

	public void setChildName(String[][] childName) {
		this.childName = childName;
	}

	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return groupName.length;
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		return childName[groupPosition].length;
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return groupName[groupPosition];
	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childName[groupPosition][childPosition];
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return groupPosition;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childPosition;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		View parentView = convertView;
		parentView = LayoutInflater.from(context).inflate(
				R.layout.multi_choice, null);
		TextView Name = (TextView) parentView
				.findViewById(R.id.multi_choice_name);
		TextView Descible = (TextView) parentView
				.findViewById(R.id.multi_choice_describe);
		Name.setText(groupName[groupPosition]);
		Descible.setText(groupDescribe[groupPosition]);
		parentView.setClickable(false);
		return parentView;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		View childView = convertView;
		// LayoutInflater layoutInflater =
		// (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		childView = LayoutInflater.from(context).inflate(
				R.layout.multi_choice_item, null);
		TextView Name = (TextView) childView
				.findViewById(R.id.multi_choice_item_optionname);
		Name.setText(childName[groupPosition][childPosition]);
		return childView;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return true;
	}

}
